/**   
 * Model Created on 2022年6月7日
 *   
 * Copyright (c) 2018 by Kunrong.HOo.
 */ 
package com.seaside.park.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seaside.common.bean.Result;
import com.seaside.park.bean.Complain;
import com.seaside.park.mapper.ComplainMapper;

/**
 * 
 * @author <a href="mailto:hoocoral@hotmail.com">Kunrong.HOo</a>
 * @version 1.0
 */
@Service
public class ComplainService {

    @Autowired
    private ComplainMapper complainMapper;
    
    public Result<IPage<Complain>> getComplainListPage(Page<Complain> page, QueryWrapper<Complain> queryWrapper) {
        IPage<Complain> iPage = complainMapper.selectPage(page, queryWrapper);
        return Result.OK("查询成功！", iPage);
    }
    
    public Result<Complain> getById(Integer alarmId) {
    	Complain alarm = complainMapper.selectById(alarmId);
    	if (alarm != null) {
    		return Result.OK("查询成功！", alarm);
    	}
    	return Result.Error("没有找到该告警！");
    }
    
    public Result<Boolean> updateComplain(Complain alarm) {
    	if (alarm != null) {
        	int updRet = complainMapper.updateById(alarm);
        	if (updRet > 0) {
        		return Result.OK("处理成功！");
        	}
    	}
    	return Result.Error("处理失败！");
    }
    
    public Result<Complain> saveComplain(Complain complain) {
    	if (complain != null) {
        	int saveRet = complainMapper.insert(complain);
        	if (saveRet > 0) {
        		return Result.OK("上报成功！");
        	}
    	}
    	return Result.Error("上报失败！");
    }
	
}